package com.thinker.loan.consumer.service.processor;

import com.thinker.loan.consumer.model.LoanApplicationRequest;
import com.thinker.loan.consumer.enumeration.LoanStatus;

public abstract class AbstractLoanProcessor implements LoanProcessor {

    private LoanProcessor next;

    @Override
    public void setNextProcessor(LoanProcessor nextProcessor) {
        this.next = nextProcessor;
    }

    @Override
    public void processChain(LoanApplicationRequest request) {
        // 体现模板模式
        this.process(request);
        if (LoanStatus.REJECTED.equals(request.getStatus())) {
            return;
        }
        if (next != null) {
            next.processChain(request);
        }
    }
}
